/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.uefs.cedoc.controle.parteII;

import br.uefs.cedoc.controle.Command;
import br.uefs.cedoc.controle.CommandException;
import br.uefs.cedoc.db.exception.DBConnectionException;
import br.uefs.cedoc.db.parteII.DBParteII;
import br.uefs.cedoc.entidades.ParteIIBean;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author suporte
 */
public class UpdateParteIICommand implements Command {
	  private String next;

	  public UpdateParteIICommand(String next) {
	    this.next = next;
	  }

    public String execute(HttpServletRequest req) throws CommandException {
        try {
            
            DBParteII dbparteII = new DBParteII();
            ParteIIBean parteII = new ParteIIBean();
            parteII.setIdParteII(Integer.parseInt(req.getParameter("id")));
            parteII.setNome(req.getParameter("nome"));
            parteII.setPrenome(req.getParameter("prenome"));
            //System.out.println("Nome: "+parteI.getNome()+" Prenome: "+parteI.getPrenome());
            dbparteII.editarParteII(parteII);
            req.setAttribute("status.msg", "ParteII atualizada!");
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (DBConnectionException ex) {
                ex.printStackTrace();
            }       
            
            return next;

    }



	}
